// eslint-disable-next-line no-unused-vars
import { Map, mergeDeep } from 'immutable';
import * as actionTypes from './constants';

const defaultState = Map({
  type: 1, // 1:单曲 10:专辑 100:歌手 1000:歌单 1002: 用户, 1004: MV, 1006: 歌词, 1009: 电台, 1014: 视频, 1018:综合
  albumCount: 0,
  songCount: 0,
  artistCount: 0,
  playlistCount: 0,
  userprofileCount: 0,
  mvCount: 0,
  djRadiosCount: 0,
  videoCount: 0,
  songs: [], // 单曲、歌词
  albums: [], // 专辑
  artists: [], // 歌手
  playlists: [], // 歌单
  userprofiles: [], //用户
  mvs: [], // mv
  djRadios: [], // 播客
  videos: [], // 视频
});

export default function reducer(state = defaultState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_SEARCH_RESULT:
      return state.mergeDeep(Map(action.result))
    default:
      return defaultState;
  }
}

// function setData(type, state, action) {
//   switch (type) {
//     case 1:
//       return state.mergeDeep({
//         songCount: action.songCount,
//         songs: action.songs
//       });
//     case 10:
//       return state.mergeDeep({
//         albumCount: action.albumCount,
//         albums: action.albums
//       });
//     case 100:
//       return state.mergeDeep({
//         artistCount: action.artistCount,
//         artists: action.artists
//       });
//     case 1000:
//       return state.mergeDeep({
//         playlistCount: action.playlistCount,
//         playlists: action.playlists
//       });
//     case 1002:
//       return state.mergeDeep({
//         userprofileCount: action.userprofileCount,
//         userprofiles: action.userprofiles
//       });
//     case 1004:
//       return state.mergeDeep({
//         mvCount: action.mvCount,
//         mvs: action.mvs
//       });
//     case 1006:
//       return state.mergeDeep({
//         songCount: action.songCount,
//         songs: action.songs
//       });
//       case 1009:
//         return state.mergeDeep({
//           djRadiosCount: action.djRadiosCount,
//           djRadios: action.djRadios
//         });
//         case 1014:
//           return state.mergeDeep({
//             videoCount: action.videoCount,
//             videos: action.videos
//           });
//   }
// }
